---
title: toUnit
description: Get the amount of a Dinero object in units.
returns: number
---

Get the amount of a Dinero object in major currency unit.

By default, the number of represented fraction digits depends on the amount and scale of the Dinero object. You can specify how many fraction digits you want to represent and pass a rounding function.

For convenience, Dinero.js provides the following rounding functions: `up`, `down`, `halfUp`, `halfDown`, `halfOdd`, `halfEven` ([bankers rounding](https://wiki.c2.com/?BankersRounding)), `halfTowardsZero`, and `halfAwayFromZero`.

## Parameters

<Parameters>

<Parameter name="dineroObject" type="Dinero<TAmount>" required={true}>

The Dinero object to format.

</Parameter>

<Parameter name="options" type="RoundingOptions<TAmount>" required={false}>

A mapping of options.

</Parameter>

<Parameter name="options.digits" type="TAmount" required={false}>

The number of fraction digits to round to.

</Parameter>

<Parameter name="options.round" type="RoundingMode" required={false}>

The rounding function to use.

</Parameter>

</Parameters>

## Code examples

### Format an object in major currency unit

```js
import { dinero, toUnit } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 1050, currency: USD });

toUnit(d); // 10.5
```

### Format an object with a custom scale

```js
import { dinero, toUnit } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 10545, currency: USD, scale: 3 });

toUnit(d); // 10.545
```

### Format an object rounded to one fraction digit

```js
import { dinero, toUnit, down } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 1055, currency: USD });

toUnit(d, { digits: 1, round: down }); // 10.5
```
